<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
    <!-- <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">-->
    <title>填充规则</title>
</head>
<body>
<canvas id="canvas"></canvas>
<script>
    function draw() {
        var ctx = document.getElementById('canvas').getContext('2d');
        ctx.beginPath();
        ctx.arc(50, 50, 40, 0, Math.PI*2, true);
        ctx.arc(50, 50, 35, 0, Math.PI*2, true);
        ctx.arc(50, 50, 25, 0, Math.PI*2, true);
        ctx.arc(50, 50, 15, 0, Math.PI*2, true);
        // 此处奇填偶不填
        ctx.fill("evenodd");//奇偶规则。http://en.wikipedia.org/wiki/Even%E2%80%93odd_rule


        ctx.beginPath();
        ctx.arc(200, 50, 30, 0, Math.PI*2, true);
        ctx.arc(200, 50, 15, 0, Math.PI*2, true);
        ctx.fill("nonzero");//默认值http://en.wikipedia.org/wiki/Nonzero-rule

    }

    draw();

</script>
</body>
</html>